﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;



namespace W1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form2_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1 form1 = new Form1();
            form1.Show();
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string b1 = textBox3.Text;
            string yoonghuName = this.textBox1.Text;
            string mimaName = this.textBox2.Text;

            if (yoonghuName == "" || mimaName == "")
            {
                MessageBox.Show("用户名或密码不能为空");
                return;

            }

            bool result=true;
            string a2 = b1.Substring(0, 2);

            if (a2 == "19" || a2 == "18")
            {
                string a1 = string.Format("insert into UserInfo1 values('{0}','{1}','{2}',1) ", textBox3.Text, textBox1.Text, textBox2.Text);
                result = DBHelper.ExecuteNonQuery(a1);

            }
            else if (a2 == "20")
            {
                string a1 = string.Format("insert into UserInfo1 values('{0}','{1}','{2}',0) ", textBox3.Text, textBox1.Text, textBox2.Text);
                result = DBHelper.ExecuteNonQuery(a1);

            }
            else
            {
                MessageBox.Show("学号或教师号错误");
                (sender as TextBox).Focus();
            }


            if (result)
            {
                MessageBox.Show("添加成功");
                Form3 form3 = new Form3();
                form3.Show();
                MessageBox.Show("");
                this.Hide();

            }
            else
            {
                MessageBox.Show("添加失败");
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void textBox3_Leave(object sender, EventArgs e)
        {

            /* string b1 = textBox3.Text;
             string a2 = b1.Substring(0, 2);

             if (a2 == "19" || a2 == "18")
             {
                 string a9 = string.Format("update UserInfo set UserInfoint='1' where Identification1id='{0}'", textBox3.Text);

                 bool result1 = DBHelper.ExecuteNonQuery(a9);
                 if (result1)
                 {
                     MessageBox.Show("添加成功");
                     Form3 form3 = new Form3();
                     form3.Show();
                 }
             }
             else if (a2 == "20")
             {
                 string a10 = string.Format("update UserInfo set UserInfoint='0' where Identification1id='{0}'", textBox3.Text);
                 bool result1 = DBHelper.ExecuteNonQuery(a10);

             }
             else
             {
                 MessageBox.Show("错误");

             }


             g a3 = string.Format("insert into UserInfo(UserInfoint) values('1') where Identification1id={0}", textBox3);



                  bool result = DBHelper.ExecuteNonQuery(a1);
                  if (result)
                  {
                      MessageBox.Show("添加成功");
                      Form3 form3 = new Form3();
                      form3.Show();
                  }
                  else
                  {
                      MessageBox.Show("添加失败");
                  }*/




        }

        private void textBox3_MouseEnter(object sender, EventArgs e)
        {
          
        }

        private void textBox3_MouseLeave(object sender, EventArgs e)
        {
           
        }
    }
}
